package com.tarena.charging.order.rabbit;

import com.tarena.charging.order.constant.RabbitConstant;
import com.tarena.charging.order.pojo.dto.OrderDelayMessageDto;
import com.tarena.charging.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class OrderDelayConsumer {
    @Autowired
    private OrderService orderService;
    //直接使用消费方法 消费dto对象
    @RabbitListener(queues = RabbitConstant.DELAY_DL_QUEUE)
    public void consume(OrderDelayMessageDto dto){
        //可以直接接收消息体数据类型dto
        try{
            orderService.checkOrderStatus(dto);
        }catch (Exception e){
            log.error("消费消息失败",e);
        }
    }
}
